import { Behaviour } from "./Behaviour.js";
import { Util } from "../utils/Util.js";
import { createSpan } from "../math/Span.js";
import { MathUtils } from "../math/MathUtils.js";
    /**
     * The Scale class is the base for the other Behaviour
     *
     * @class Behaviour
     * @constructor
     */

    /**
 * The Scale class is the base for the other Behaviour
 *
 * @class Behaviour
 * @constructor
 */
export class Scale extends Behaviour {
    constructor(a, b, life, easing) {
        super( life, easing);
        this.reset(a, b);
        this.name = "Scale";
    }
    reset(a, b, life, easing) {
        if (b == null || b == undefined)
            this._same = true;

        else
            this._same = false;

        this.a = createSpan(Util.initValue(a, 1));
        this.b = createSpan(b);

        life && super.reset( life, easing);
    }
    initialize(particle) {
        particle.transform.scaleA = this.a.getValue();
        particle.transform.oldRadius = particle.radius;
        if (this._same)
            particle.transform.scaleB = particle.transform.scaleA;

        else
            particle.transform.scaleB = this.b.getValue();

    }
    applyBehaviour(particle, time, index) {
        super.applyBehaviour( particle, time, index);
        particle.scale = MathUtils.lerp(particle.transform.scaleA, particle.transform.scaleB, this.energy);

        if (particle.scale < 0.0005) particle.scale = 0;
        particle.radius = particle.transform.oldRadius * particle.scale;
    }
}






;
